<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Redis;
class DeleteFailedJobs extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'tx:del-failed-jobs';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '删除 redis 中失败的队列';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        if ($this->confirm('!!!该命令将清空所有失败的队列，请确认是否要删除? [y/n]')) {
            Redis::connection()->del('horizon:failed:*');
            Redis::connection()->del('horizon:failed_jobs');
            Redis::connection()->del('horizon');
        }
    }
}
